<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%
request.setAttribute("locale",request.getLocale());
%>
<script type="text/javascript">
var tdTips1 = "四至名称",
tdTips2 = "坐标信息";
function tdInputBlur(_obj){
var val = $(_obj).val(),
	idx = $(_obj).closest("td").index();
//未输入时恢复提示
if(val==""&&idx==1){
	val = tdTips1;
}
if(val==""&&idx==2){
	val = tdTips2;
}
$(_obj).next().val(val);
$(_obj).prev().text(val).show();
$(_obj).remove();
}

$.fn.addFBTr = function(){
//按标签页为name添加数字，从1开始
var div = $(".forestInfoTabs>.tabsContent>div").has(this),
	num = div.index()+1,
	tr = '\
	<tr class="fbNewAdded">\
		<td width="22"><input type="checkbox" name="fbCheck*'+num+'" class="checkboxCtrl"></td>\
		<td class="tdInput"><div><input type="text" name="rights_add_fourName*'+num+'" class="textInput" value="" size="50"/></div></td>\
		<td class="tdInput"><div><input type="text" name="rights_add_corXY*'+num+'" class="textInput" value="" size="50"/></div></td>\
	</tr>';
$(this).click(function(){
	$(".fourBoundaries .gridTbody tbody",div).append(tr);
	$(".fbNewAdded").bind("mouseover",function(){
		$(this).addClass("hover");
	}).bind("mouseout",function(){
		$(this).removeClass("hover");
	}).bind("click",function(){
		$(this).addClass("selected").siblings().removeClass("selected");
	}).siblings().bind("click",function(){
		$(this).siblings().removeClass("selected");
	});
});
};

$.fn.removeFBTr = function(){
var div = $(".forestInfoTabs>.tabsContent>div").has(this);
$(this).click(function(){
	var tr = $(".fourBoundaries .gridTbody tbody tr",div);
	if($("input:checked",tr).length>0){
		$("input:checked",tr).closest("tr").remove();
	}else if(tr.hasClass("selected")){
		$("tr.selected",tr.parent()).remove();
	}else{
		alertMsg.warn("没有选择任何条目！");
	}
});
};

function switchTabs(_obj){
$(".forestInfoTabs .tabsHeader ul li").removeClass("selected");
$(".forestInfoTabs .tabsContent>div").hide();
if(_obj==undefined||_obj==null){
	$(".forestInfoTabs .tabsHeader ul li:last").addClass("selected");
	$(".forestInfoTabs .tabsContent>div:last").show();
}else{
	var idx = $(".forestInfoTabs .tabsHeader ul li").index(_obj);
	$(".forestInfoTabs .tabsHeader ul li").eq(idx).addClass("selected");
	$(".forestInfoTabs .tabsContent>div").eq(idx).show();
}
}

function addRightPhoto(num,showPhotoPath,photoIdPath){
var signIndex=photoIdPath.indexOf(";");
var photoId=photoIdPath.substring(0,signIndex);
var photoPath=photoIdPath.substr(signIndex+1);
li = '\
<li style="float:left;border:1px solid #ccc;padding:2px;margin:5px;">\
	<input name="photoIdPaths" value="'+photoIdPath+'" type="checkbox"/>\
	<input name="rights_add_photoId*'+num+'" value="'+photoId+'" type="hidden"/>\
	<input name="rights_add_photoPath*'+num+'" value="'+photoPath+'" type="hidden"/>\
	<img src="'+showPhotoPath+'" width="135" height="95"/>\
</li>';
$("#photoContent"+num).append(li);
}

$(function(){
$("#addForestInfo").click(function(){
	var num = $(".forestInfoTabs .tabsHeaderContent ul li").size()+1,
		sw = '<li><a href="javascript:;"><span>林地信息'+num+'</span></a></li>',
		ct = $(".forestInfoTabs .tabsContent>div").eq(0).clone(true);
	$(".forestInfoTabs .tabsHeaderContent ul").append(sw);
	$(".forestInfoTabs .tabsContent").append(ct);
	switchTabs();
	$(".raaItems",ct).attr("id","rights_add_atrId*"+num).attr("name","rights_add_atrId*"+num);
	$(".fourBoundaries .toolBar a.add",ct).attr("id","addFB"+num).addFBTr();
	$(".fourBoundaries .toolBar a.delete",ct).attr("id","removeFB"+num).removeFBTr();
	$(".fourBoundaries .gridHeader input.checkboxCtrl",ct).attr("group","fbCheck*"+num);
	$(".fourBoundaries .gridTbody tbody",ct).empty();
	$(".photoContent ul",ct).attr("id","photoContent"+num).empty();
	$(":input",ct).not(":button, :submit, :checkbox").val("");
	$(":input",ct).not(":button, :submit,").removeAttr("checked").removeAttr("selected");
	
	var href=$("#showAddPhoto",ct).attr("href");
	href=href.substring(0,href.indexOf("tabIndex=")+9)+num;
	$("#showAddPhoto",ct).attr("href",href);
});
$(".forestInfoTabs .tabsHeader ul li").live("click",function(){
	switchTabs(this);
});

$("[id^='addFB']").each(function(){
	$(this).addFBTr();
});
$("[id^='removeFB']").each(function(){
	$(this).removeFBTr();
});

//文字的一些响应
//	$(".tdInput span").live("click",function(){
//		if($(this).text()==tdTips1||$(this).text()==tdTips2){
//			$(this).text("");
//		}
//		var ipt = "<input type='text' value='"+$(this).text()+"' />";
//		$(ipt).insertAfter(this).focus();
//		$(this).hide();
//	}).live("mouseover",function(){
//		$(this).css({
//			"background":"#fff",
//			"border":"1px solid #aaa",
//			"padding":"2px"
//		});
//	}).live("mouseout",function(){
//		$(this).css({
//			"background":"none",
//			"border":"none",
//			"padding":"0"
//		});
//	});
//	$(".tdInput input:text").live("blur",function(){
//		tdInputBlur(this);
//	});
});

function rightsModifySubmit(formObj){
	$("input[name^='rights_modify']").each(function(){
		if($(this).val()==""){
			$(this).attr("value"," ");
		}
	});
	return validateCallback(formObj,navTabAjaxDone);
}
</script>

<div class="pageContent">
	<form method="post" action="<c:url value="/rights/rightsModify.shtml"/>" class="pageForm required-validate" onsubmit="return rightsModifySubmit(this);">
		<div class="pageFormContent" layoutH="56">
			<p>
				<label>林权证编号：</label>
				<input type="hidden" name="rights_modify_fstRigId"  id="rights_modify_fstRigId" value="${rights.fstRigId}"/>
				<input type="text" name="rights_modify_rigCode"  id="rights_modify_rigCode" size="30" value="${rights.rigCode}"/>
			</p>
			<p>
				<label>林权证号：</label>
				<input type="text" name="rights_modify_rigNumber"  id="rights_modify_rigNumber" size="30" value="${rights.rigNumber}"/>
			</p>
			<p>
				<label>身份证号：</label>
				<input type="text" name="rights_modify_idCards"  id="rights_modify_idCards" size="30" value="${rights.idCards}"/>
			</p>
			<p>
				<label>法定代表人：</label>
				<input type="text" name="rights_modify_legal"  id="rights_modify_legal" size="30" value="${rights.legal}"/>
			</p>
			<p style="width:760px">
				<label>通讯地址：</label>
				<input type="text" name="rights_modify_address"  id="rights_modify_address" size="93" value="${rights.address}"/>
			</p>
			<p style="width:760px">
				<label>单位（个人）：</label>
				<input type="text" name="rights_modify_unit"  id="rights_modify_unit" size="93" value="${rights.unit}"/>
			</p>
			
			<div style="clear:both;"></div>
			
			<div class="panelBar" style="border-left: 1px solid #B8D0D6;border-right: 1px solid #B8D0D6;border-bottom:none;">
				<ul class="toolBar">
					<li><span>林地信息</span></li>
					<li class="line">line</li>
					<li><a class="add" href="#" id="addForestInfo"><span><spring:message code="search.btnGoAdd"/></span></a></li>
				</ul>
			</div>
			<div class="tabs forestInfoTabs">
				<div class="tabsHeader">
					<div class="tabsHeaderContent">
						<ul>
							<c:forEach items="${rights.alWoodlandList}" var="woodland" varStatus="w">
							<li>
								<a href="javascript:;"><span>林地信息${w.index+1}</span></a>
								<a class="close" href="javascript:;">close</a>
							</li>
							</c:forEach>
						</ul>
					</div>
				</div>
				<div class="tabsContent" style="background:#fff;">
					<c:forEach items="${rights.alWoodlandList}" var="woodland" varStatus="w">
					<div>
						<p>
							<label>申请表编号：</label>
							<input type="text" name="rights_modify_appNumber" id="rights_modify_appNumber" size="30" value="${woodland.appNumber}"/>
						</p>
						<p>
							<label>登记类型：</label>
							<select name="rights_modify_rstType" id="rights_modify_rstType">
			                	<option value="">--请选择--</option>
			          			<c:forEach items="${rstTypeList}" var="atrRstType">
			           				<option value="${atrRstType.atrValue}" <c:if test="${woodland.rstType==atrRstType.atrValue}">selected="selected"</c:if>>${atrRstType.atrName}</option>
			           			</c:forEach>
			                </select>
						</p>
						<p>
							<label>是否抵押：</label>
							<select name="rights_modify_mortgage" id="rights_modify_mortgage">
			                	<option value="">--请选择--</option>
			                	<option value="1" <c:if test="${woodland.mortgage==1}">selected="selected"</c:if>>是</option>
			                	<option value="0" <c:if test="${woodland.mortgage==0}">selected="selected"</c:if>>否</option>
			          		</select>
						</p>
						<p>
							<label>是否退耕还林地：</label>
							<select name="rights_modify_backForest" id="rights_modify_backForest">
			                	<option value="">--请选择--</option>
			                	<option value="1" <c:if test="${woodland.backForest==1}">selected="selected"</c:if>>是</option>
			                	<option value="0" <c:if test="${woodland.backForest==0}">selected="selected"</c:if>>否</option>
			          		</select>
						</p>
						<p>
							<label>林地所有权权利人：</label>
							<select name="rights_modify_fstOwn" id="rights_modify_fstOwn">
			                	<option value="">--请选择--</option>
			          			<c:forEach items="${fstOwnList}" var="atrFstOwn">
			           				<option value="${atrFstOwn.atrValue}" <c:if test="${woodland.fstOwn==atrFstOwn.atrValue}">selected="selected"</c:if>>${atrFstOwn.atrName}</option>
			           			</c:forEach>
			                </select>
						</p>
						<p>
							<label>林地使用权权利人：</label>
							<input type="text" name="rights_modify_fstUse" id="rights_modify_fstUse" size="30" value="${woodland.fstUse}"/>
						</p>
						<p>
							<label>森林或林木所有权权利人：</label>
							<input type="text" name="rights_modify_woodOwn" id="rights_modify_woodOwn" size="30" value="${woodland.woodOwn}"/>
						</p>
						<p>
							<label>森林或林木使用权权利人：</label>
							<input type="text" name="rights_modify_woodUse" id="rights_modify_woodUse" size="30" value="${woodland.woodUse}"/>
						</p>
						<p>
							<label>坐落：</label>
							<input type="hidden" name="rights_modify.areaId" id="rights_modify_areaId" value="${woodland.areaId}"/>
	                    	<input type="text" name="rights_modify.areaName" id="rights_modify_areaName" readonly="readonly" value="${woodland.areaName}"/>
                    		<a class="btnLook" href="<c:url value="/rights/goAreaLookup.shtml"/>" lookupGroup="rights_modify">选择所属地区</a>
		                    <a class="btnClean" href="javascript:;" onclick="$('#rights_modify_areaId').val('');$('#rights_modify_areaName').val('');">清空</a>
						</p>
						<p>
							<label>小地名：</label>
							<input type="text" name="rights_modify_smallTo" id="rights_modify_smallTo" size="30" value="${woodland.smallTo}"/>
						</p>
						<p>
							<label>林班：</label>
							<input type="text" name="rights_modify_fstClass" id="rights_modify_fstClass" size="30" value="${woodland.fstClass}"/>
						</p>
						<p>
							<label>小班：</label>
							<input type="text" name="rights_modify_smallCls" id="rights_modify_smallCls" size="30" value="${woodland.smallCls}"/>
						</p>
						<p>
							<label>面积（亩）：</label>
							<input type="text" name="rights_modify_acreage" id="rights_modify_acreage" size="30" value="${woodland.acreage}"/>
						</p>
						<dl class="nowrap">
							<dt>主要树种：</dt>
							<dd>
							<c:forEach items="${speciesList}" var="atrSpecies">
							<input type="checkbox" name="rights_modify_atrId*${w.index+1}" id="rights_modify_atrId*${w.index+1}" value="${atrSpecies.atrId}" 
							<c:forEach items="${woodland.alWoodlandSpeciesList}" var="woodSpecies">
							<c:if test="${atrSpecies.atrId==woodSpecies.atrId}">checked="checked"</c:if>
							</c:forEach>
							>${atrSpecies.atrName}&nbsp;&nbsp;
							</c:forEach>
							</dd>
						</dl>
						<p>
							<label>蓄积或株数：</label>
							<input type="text" name="rights_modify_treesNum" id="rights_modify_treesNum" size="30" value="${woodland.treesNum}"/>
						</p>
						<p>
							<label>造林年度：</label>
							<input class="Wdate" type="text" id="rights_modify_affDate" name="rights_modify_affDate" onFocus="WdatePicker({dateFmt:'yyyy'})" readonly="readonly" value="<fmt:formatDate value="${woodland.affDate}" pattern="yyyy"/>"/>
						</p>
						<p>
							<label>地类：</label>
							<select name="rights_modify_landType" id="rights_modify_landType">
			                	<option value="">--请选择--</option>
			          			<c:forEach items="${landTypeList}" var="atrLandType">
			           				<option value="${atrLandType.atrValue}" <c:if test="${woodland.landType==atrLandType.atrValue}">selected="selected"</c:if>>${atrLandType.atrName}</option>
			           			</c:forEach>
			                </select>
						</p>
						<p>
							<label>森林分类：</label>
							<select name="rights_modify_fstType" id="rights_modify_fstType">
			                	<option value="">--请选择--</option>
			          			<c:forEach items="${fstTypeList}" var="atrFstType">
			           				<option value="${atrFstType.atrValue}" <c:if test="${woodland.fstType==atrFstType.atrValue}">selected="selected"</c:if>>${atrFstType.atrName}</option>
			           			</c:forEach>
			                </select>
						</p>
						<p>
							<label>林种：</label>
							<select name="rights_modify_fstSpecies" id="rights_modify_fstSpecies">
			                	<option value="">--请选择--</option>
			          			<c:forEach items="${fstSpeciesList}" var="atrFstSpecies">
			           				<option value="${atrFstSpecies.atrValue}" <c:if test="${woodland.fstSpecies==atrFstSpecies.atrValue}">selected="selected"</c:if>>${atrFstSpecies.atrName}</option>
			           			</c:forEach>
			                </select>
						</p>
						<p>
							<label>林地使用期（年）：</label>
							<input type="text" name="rights_modify_fstUseDate" id="rights_modify_fstUseDate" size="30" value="${woodland.fstUseDate}"/>
						</p>
						<p>
							<label>终止日期：</label>
							<input class="Wdate" type="text" id="rights_modify_endDate" name="rights_modify_endDate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" value="<fmt:formatDate value="${woodland.endDate}" pattern="yyyy-MM-dd"/>"/>
						</p>
						<p>
							<label>坡度：</label>
							<input type="text" name="rights_modify_slope" id="rights_modify_slope" size="30" value="${woodland.slope}"/>
						</p>
						<p>
							<label>坡向：</label>
							<input type="text" name="rights_modify_aspect" id="rights_modify_aspect" size="30" value="${woodland.aspect}"/>
						</p>
						<p>
							<label>档案柜编号：</label>
							<input type="text" name="rights_modify_cabinetNum" id="rights_modify_cabinetNum" size="30" value="${woodland.cabinetNum}"/>
						</p>
						
						<div class="divider"></div>
						<div class="pageContent fourBoundaries" style="border-left: 1px solid #B8D0D6;border-right: 1px solid #B8D0D6;width:70%">
							<div class="panelBar">
								<ul class="toolBar">
									<li><span>四至</span></li>
									<li class="line">line</li>
									<li><a class="add" href="#" id="addFB1"><span><spring:message code="search.btnGoAdd"/></span></a></li>
									<li><a class="delete" href="#" id="removeFB1"><span><spring:message code="search.btnRemove"/></span></a></li>
								</ul>
							</div>
							<table class="table" width="100%">
								<thead>
									<tr>
										<th width="22"><input type="checkbox" group="fbCheck*1" class="checkboxCtrl"></th>
										<th>名称</th>
										<th>坐标</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${woodland.alWoodlandFourList}" var="four">
									<tr>
										<td width="22"><input type="checkbox" group="fourIds" class="checkboxCtrl" value="${four.fourId}"></td>
										<td class="tdInput"><input type="text" name="rights_modify_fourName*${w.index+1}" value="${four.fourName}" size="50"/></td>
										<td class="tdInput"><input type="text" name="rights_modify_corXY*${w.index+1}" value="${four.corX}、${four.corY}" size="50"/></td>
									</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
						<div class="divider"></div>
						<div class="pageContent" style="border-left: 1px solid #B8D0D6;border-right: 1px solid #B8D0D6;border-bottom: 1px solid #B8D0D6;width:70%">
							<div class="panelBar">
								<ul class="toolBar">
									<li><span>图片</span></li>
									<li class="line">line</li>
									<li><a class="add" id="showAddPhoto" href="<c:url value="/rights/goRightsPhotoAdd.shtml"/>?tabIndex=${w.index+1}" target="dialog" width="420"><span><spring:message code="search.btnGoAdd"/></span></a></li>
									<li><a class="delete" title="确实要删除这些记录吗?" target="selectedTodo" rel="photoIdPaths" href="<c:url value="/rights/photoRemoveBat.shtml"/>"><span><spring:message code="search.btnRemove"/></span></a></li>
								</ul>
							</div>
							<div class="photoContent">
								<ul id="photoContent${w.index+1}">
									<c:forEach items="${woodland.alWoodlandPhotoList}" var="photo">
									<li style="float:left;border:1px solid #ccc;padding:2px;margin:5px;">
										<input name="photoIdPaths" value="${photo.photoId};${photo.photoPath}" type="checkbox"/>
										<input name="rights_modify_photoId*${w.index+1}" value="${photo.photoId}" type="hidden"/>
										<input name="rights_modify_photoPath*${w.index+1}" value="${photo.photoPath}" type="hidden"/>
										<img src="<c:url value="${photo.photoPath}"/>" width="135" height="95"/>
									</li>
									</c:forEach>
								</ul>
							</div>
						</div>
						<div class="divider"></div>
						<dl class="nowrap">
							<dt>主要权利依据：</dt>
							<dd><textarea rows="2" cols="80" name="rights_modify_basis" id="rights_modify_basis" class="textInput">${woodland.basis}</textarea></dd>
						</dl>
						<dl class="nowrap">
							<dt>林权共有者说明：</dt>
							<dd><textarea rows="2" cols="80" name="rights_modify_explain" id="rights_modify_explain" class="textInput">${woodland.explain}</textarea></dd>
						</dl>
						<dl class="nowrap">
							<dt>注记：</dt>
							<dd><textarea rows="2" cols="80" name="rights_modify_note" id="rights_modify_note" class="textInput">${woodland.note}</textarea></dd>
						</dl>
						<p>
							<label>外业调查人：</label>
							<input type="text" name="rights_modify_invPerson" id="rights_modify_invPerson" size="30" value="${woodland.invPerson}"/>
						</p>
						<p>
							<label>经办人：</label>
							<input type="text" name="rights_modify_hdePerson" id="rights_modify_hdePerson" size="30" value="${woodland.hdePerson}"/>
						</p>
						<p>
							<label>负责人：</label>
							<input type="text" name="rights_modify_crgPerson" id="rights_modify_crgPerson" size="30" value="${woodland.crgPerson}"/>
						</p>
						<p>
							<label>发证日期：</label>
							<input class="Wdate" type="text" id="rights_modify_issueDate" name="rights_modify_issueDate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" value="<fmt:formatDate value="${woodland.issueDate}" pattern="yyyy-MM-dd"/>"/>
						</p>
					</div>
					</c:forEach>
				</div>
				<div class="tabsFooter">
					<div class="tabsFooterContent"></div>
				</div>
			</div>
					
			<div class="divider"></div>
		</div>
		<div class="formBar">
			<ul>
        		<c:if test="${p:isPower('/rights/rightsModify.shtml',sessionScope.loginAccount)}">
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit"><spring:message code="modify.btnModify"/></button></div></div></li>
				</c:if>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close"><spring:message code="page.btnClose"/></button></div></div></li>
			</ul>
		</div>
	</form>
</div>
